package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeeDTO;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 添加员工
     * @param employee
     */
    @AutoFill(OperationType.INSERT)
    void insertEmployee(@Param("employee") Employee employee);

    /**
     * 分页查询员工信息
     * @param employeePageQueryDTO
     * @return
     */
    Page<Employee> selectEmp(@Param("empDTO") EmployeePageQueryDTO employeePageQueryDTO);


    /**
     * 根据ID查询员工信息
     * @param id
     * @return
     */
    Employee selectEmpById(@Param("id") Long id);

    /**
     * 修改员工信息
     * 启用用禁用员工
     * 修改密码
     * @param employee
     */
    @AutoFill(OperationType.UPDATE)
    void updateEmployee(@Param("employee") Employee employee);

    /**
     * 根据ID搜索在数据库中的密码
     * @param empId
     * @return
     */
    String selectEmpPasswordById(@Param("empId") Long empId);
}
